//创建快捷服务 需要引进fastService.css 
var serviceOptions = new Array();
serviceOptions[0] = new Array('/wh/gd/14646.shtml','dfpic_signIn','服务承诺');
serviceOptions[1] = new Array('../../../view/insuranceClaim/claimMain.jsp-showflag=1.htm'/*tpa=http://www.95590.cn/ebiz/view/insuranceClaim/claimMain.jsp?showflag=1*/,'dfpic_policy','保单查询');
serviceOptions[2] = new Array('../../../view/onlineBusinessNew/businessMain.jsp-showflag=3.htm'/*tpa=http://www.95590.cn/ebiz/view/onlineBusinessNew/businessMain.jsp?showflag=3*/,'dfpic_premiums','支付保费');
serviceOptions[3] = new Array('/lpwd/index.shtml','dfpic_branch','服务网点');
serviceOptions[4] = new Array('../../../view/insuranceClaim/claimMain.jsp-showflag=1.htm'/*tpa=http://www.95590.cn/ebiz/view/insuranceClaim/claimMain.jsp?showflag=1*/,'dfpic_claims','理赔查询');
serviceOptions[5] = new Array('../../../view/onlineBusinessNew/businessMain.jsp-showflag=52.htm'/*tpa=http://www.95590.cn/ebiz/view/onlineBusinessNew/businessMain.jsp?showflag=52*/,'dfpic_activation','电子发票');
serviceOptions[6] = new Array('/cpsg/gcbj/index.shtml?resource=baoXianXuBao','dfpic_renewal','保险续保');
serviceOptions[7] = new Array('/cpsg/gcbj/cxchq/','dfpic_todayActive','特色服务');
var hostname = location.hostname;
//2016年度双十一活动起止时间  每天时间段:08:00:00-20:00:00
var act_start = "2016/11/01";//开始时间
var act_end = "2016/11/11";//结束时间
//生产环境的地址
if("http://www.95590.cn/ebiz/res/js/2015TopAndButtom/www.95590.cn" == hostname || "http://www.95590.cn/ebiz/res/js/2015TopAndButtom/m.4009666666.cn" == hostname){
   serviceOptions[0] = new Array('/wh/gd/16051.shtml','dfpic_signIn','积分指南');
}
$(document).ready(function(){
	//引入css /css/fastService.css 
	var baseUrl = location.protocol+"//"+location.host;
	if(hostname=="127.0.0.1" || hostname=="localhost"){
		baseUrl = "../../../../index.htm"/*tpa=http://www.95590.cn/*/;
		baseUrl = "http://10.1.12.84:8081/";
	}
	var css_url = baseUrl+"/css/fastService.css";
	$("head").append($("<link rel='stylesheet' type='text/css' href='"+css_url+"'/>"));
	//创建快捷服务
	var div_over = $("<a id=\"fw_over\" class=\"\" href=\"javascript:void(0);\" style=\"background: #015eac;color: #fff;padding: 10px 6px;width: 20px;text-align: center;font-size: 16px;border-radius: 12px 0px 0px 12px;text-decoration: none;display: block; position: fixed;right: 0px;top: 314px;letter-spacing: 0px;z-index: 999;line-height: 1.4;\">更多服务</a>");
	var div_jf_block = $("<div class='df_integralMalll' onclick='clickManage(&quot;integralMall&quot;);'></div>");
	var div_block = $("<div class='df_the_toolbar'></div>");
	var div0_block = $("<div class='df_thetopic'></div>");
	var a = "";
	a+="<a class='df_tooll' href='javascript:void(0);' ></a>";
	a+="<a class='df_toolg' href='javascript:void(0);' ></a>";
	a+="<a class='df_toolk' href='javascript:void(0);' onclick='clickManage_new();'></a>";
	a+="<a class='df_tools' href='javascript:void(0);' onclick='clickManage(&quot;df_tools&quot;);'></a>";
	div0_block.append($(a));
	div_block.append(div_over);
	div_block.append(div_jf_block);
	div_block.append(div0_block);
	$('body').append(div_block);
	
	//快捷服务栏鼠标覆盖事件
	$('.df_thetopic').find('a').each(function(index){
		$(this).hover(function(){
			var className = this.className;
			var newClassName = className.split('_')[0]+'_'+className.split('_')[1]+'_red';
			$(this).removeClass();//清除原先Class
			$(this).css("background-image","");
			$(this).attr('class',newClassName);
			if(0==index){
				clickManage("df_tooll");
			}else if(1==index){
				clickManage("df_toolg");
			}
		}, function(){
			var className = this.className;
			var newClassName = className.split('_')[0]+'_'+className.split('_')[1];
			$(this).removeClass();//清除原先Class
			$(this).css("background-image","");
			$(this).attr('class',newClassName);				
		});
	});
	
	//快捷服务栏鼠标悬停时展开
	$(".df_the_toolbar").hover(function(){
		var str = $("#fw_over").css("right")+"";
	    if(str=="0px"){
	    	$(".df_integralMalll").animate({right:'1px'});
	    	$(".df_the_toolbar").animate({right:'1px'});
			$("#fw_over").animate({right:'50px'});
	    }
	},function(){
		var str = $("#fw_over").css("right")+"";
	    if(str=="50px"){
			$("#fw_over").animate({right:'0px'});
	    	$(".df_integralMalll").animate({right:'-49px'});
	    	$(".df_the_toolbar").animate({right:'-49px'});
	    }
	});
});

//点击事件管理
function clickManage(param){
	//判断是否已有展开项
	if($(".df_the_toolbar").find("ul.df_thetoolz").length>0){
	   $(".df_the_toolbar").find("ul.df_thetoolz").remove();
	   removeSelectedClass("df_tooll","df_tooll_red");//去除选中状态
	   removeSelectedClass("df_toolg","df_toolg_red");//去除选中状态
	}
	if("df_tooll"==param){//公告小喇叭
	   addSelectedClass("df_tooll","df_tooll_red");
	   $(".df_the_toolbar").append(bulletion());
	   $(".df_codearrow").css("top","20px");
	   $(".df_the_toolbar").find("ul.df_thetoolz").show();
	   setTimeout(function(){
		   $(".df_the_toolbar").find("ul.df_thetoolz").remove();
		   removeSelectedClass("df_tooll","df_tooll_red");//去除选中状态
	       },4500);
	}else if("df_toolg"==param){//8个快捷服务选项
	   addSelectedClass("df_toolg","df_toolg_red");		
	   $(".df_the_toolbar").append(fastService());
	   $(".df_codearrow").css("top","66px");
	   $(".df_the_toolbar").find("ul.df_thetoolz").show();
	   setTimeout(function(){
		   $(".df_the_toolbar").find("ul.df_thetoolz").remove();
		   removeSelectedClass("df_toolg","df_toolg_red");//去除选中状态
	       },4500);	   		
	}else if("df_toolk"==param){ //在线客服
	   addSelectedClass("df_tooll","df_tooll_red");		
	   if($.isFunction(window.cmCreateElementTag)){
		  cmCreateElementTag("在线客服","在线客服" );//IBM监测代码
	   }
	   serviceOnlineByChannel('xinBao');
	}else if("df_tools"==param){ //返回顶部
		$('body,html').animate({scrollTop: 0},700);
	}else if("integralMall"==param){//积分商城
		window.open("http://jf.95590.cn/","_blank");
	}
}
	
//创建公告
function bulletion(){
   var ul = $("<ul class='df_thetoolz' style='width:320px;'></ul>");
   var url = location.protocol+"//"+location.host+"/gg/bulletin_iframe2/";
   var iframe = $("<iframe width='250px' scrolling='no' frameborder='0' src='"+url+"'></iframe>");
   var div1_block = "<div class='df_codearrow'><em></em><span></span></div>";
   ul.append(iframe);
   ul.append($(div1_block));	   
   return ul;
}
//创建8个快捷服务选项
function fastService(){
	var ul = $("<ul class='df_thetoolz' style='width:320px;'></ul>");
	var lis = '';
	for(var i in serviceOptions){
		lis += "<li class='df_picwd'><a href="+serviceOptions[i][0]+" target='_blank'><i class="+serviceOptions[i][1]+"></i>"+serviceOptions[i][2]+"</a></li>";
	}
	var div1_block = "<div class='df_codearrow'><em></em><span></span></div>";
	ul.append($(lis));
	ul.append($(div1_block));		
	return ul;		
}
//添加选中状态
function addSelectedClass(unSelectedClass, selectedClass){
	   var obj = $("."+unSelectedClass);
	   obj.removeClass();//清除原先Class
	   obj.css("background-image","");
	   obj.attr("class",selectedClass);		
}
//取消选中状态
function removeSelectedClass(unSelectedClass, selectedClass){
	   var obj = $("."+selectedClass);
	   obj.removeClass();//清除原先Class
	   obj.css("background-image","");
	   obj.attr("class",unSelectedClass);	
}

//2017/9/22 客服入口改造(智齿客服)
function clickManage_new(){
	zhiManager.set('moduleType',4);
	zhiManager.expand();
}